package cn.tedu.car.backend.order.controller;

import cn.tedu.car.backend.base.response.JsonResult;
import cn.tedu.car.backend.order.service.OrderService;
import cn.tedu.car.backend.order.pojo.dto.OrderParam;
import cn.tedu.car.backend.order.pojo.dto.OrderQuery;
import cn.tedu.car.backend.order.pojo.vo.OrderVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/order")
public class OrderController {
    @Autowired
    OrderService orderService;
    @PostMapping("/save")
    public JsonResult saveOrder(OrderParam orderParam) {
        log.debug("新增订单信息，SaveParam={}", orderParam);
        orderService.saveOrder(orderParam);
        return JsonResult.ok();
    }
    @GetMapping("/select")
    public JsonResult selectOrder(OrderQuery orderQuery) {
        log.debug("查询订单:orderQuery={}",orderQuery);
        List<OrderVO> list = orderService.selectOrder(orderQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("/update")
    public JsonResult updateOrder(OrderParam orderParam) {
        log.debug("新增订单信息，SaveParam={}", orderParam);
        orderService.updateOrder(orderParam);
        return JsonResult.ok();
    }

}
